<template>
	<view class="indexs">
		<view :class="'header ' + (banertrue ? 'header_lan' : '')" :style="'padding-top: ' + navH + 'px;'">
			<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
				<view class="index_h_cont3">
					<view class="index_wenben_img" @tap="jumpzuo">
						<image :src="imgUrl + '/dzx_img22.png'" mode="widthFix"></image>
					</view>
					<view class="index_wenben baise">{{ $t('page_sharing_order_detail.my_order') }}</view>
				</view>
			</view>
			<view class="coloe_title">s</view>
		</view>
		<view class="index_center">
			<view class="pintuan_dingdan_details" :style="'padding-top: ' + 50  + 'px;'">
				<block v-for="(item, index) in arrlist" v-key="index">
					<view class="pintuan_dingdan_details_item1" v-if="item.id == (xiangqingdetail.status?xiangqingdetail.status.value:0)"><image :src="imgUrl + '/' + item['img']"></image></view>
				</block>
				<view class="pintuan_dingdan_details_item2">
					<view class="pintuan_dingdan_details_item2_l">
						<image :src="imgUrl + '/dzx_img45.png'"></image>
						<view class="pintuan_dingdan_details_item2_l_txt">
							<view class="pintuan_dingdan_details_item2_l1">
							{{ xiangqingdetail.address?xiangqingdetail.address.name:'' }} 
							{{ xiangqingdetail.address?xiangqingdetail.address.phone:"" }}</view>
							<view class="pintuan_dingdan_details_item2_l2">
								{{ xiangqingdetail.address?xiangqingdetail.address.country:"" }}
								{{ xiangqingdetail.address?xiangqingdetail.address.province:"" }}
								{{ xiangqingdetail.address?xiangqingdetail.address.city:"" }}
								{{ xiangqingdetail.address?xiangqingdetail.address.region:""}}
								{{ xiangqingdetail.address?xiangqingdetail.address.address:"" }}
							</view>
						</view>
					</view>
					<view class="pintuan_dingdan_details_item2_r" @click="changeAddress">{{ $t('page_sharing_order_detail.replace') }}</view>
				</view>
				<view class="pintuan_dingdan_details_item3"><image :src="imgUrl + '/dzx_img46.png'"></image></view>
				<view class="pintuan_dingdan_details_item4">
					<view class="pintuan_dingdan_details_item4_title">
						<image :src="imgUrl + '/dzx_img51.png'"></image>
						<text>{{ $t('page_sharing_order_detail.order_number') }}{{ xiangqingdetail['order_sn'] }}</text>
					</view>
					<view class="pintuan_dingdan_details_item4_dis">
						<image :src="imgUrl + '/dzx_img27.png'"></image>
						<text>{{ xiangqingdetail.title }}</text>
					</view>
					<view class="pintuan_dingdan_details_item4_list">
						<view class="pintuan_dingdan_details_item4_cont">
							<view class="pintuan_dingdan_details_item4_t1">{{ $t('page_sharing_order_detail.consolidation_warehouse') }}</view>
							<view class="pintuan_dingdan_details_item4_t2">{{ xiangqingdetail.storage?xiangqingdetail.storage['shop_name']:"" }}</view>
						</view>
						<view class="pintuan_dingdan_details_item4_cont">
							<view class="pintuan_dingdan_details_item4_t1">{{ $t('page_sharing_order_detail.Express_way') }}</view>
							<view class="pintuan_dingdan_details_item4_t2">{{ xiangqingdetail.line?xiangqingdetail.line['name']:"" }}</view>
						</view>
						<view class="pintuan_dingdan_details_item4_cont">
							<view class="pintuan_dingdan_details_item4_t1">{{ $t('page_sharing_order_detail.Opening_time') }}</view>
							<view class="pintuan_dingdan_details_item4_t2">{{ xiangqingdetail.start_time }}</view>
						</view>
						<view class="pintuan_dingdan_details_item4_cont">
							<view class="pintuan_dingdan_details_item4_t1">{{ $t('page_sharing_order_detail.ktrs') }}</view>
							<view class="pintuan_dingdan_details_item4_t2">{{ xiangqingdetail.max_people }}</view>
						</view>
						<view class="pintuan_dingdan_details_item4_cont">
							<view class="pintuan_dingdan_details_item4_t1">{{ $t('page_sharing_order_detail.qyzl') }}</view>
							<view class="pintuan_dingdan_details_item4_t2">{{ xiangqingdetail.min_weight }}{{ weight_mode.unit }}</view>
						</view>
					</view>
				</view>
				<view class="pintuan_dingdan_details_item5">
					<view class="pintuan_dingdan_details_item5_title">
						<image :src="imgUrl + '/dzx_img47.png'"></image>
						<text>{{ $t('page_sharing_order_detail.xzlx') }}</text>
					</view>
					<view class="pintuan_dingdan_details_item5_dis">
						<image :src="imgUrl + '/dzx_img15.png'" mode="aspectFill"></image>
						<view class="pintuan_dingdan_details_item5_txt">
							<view class="pintuan_dingdan_details_item5_t1">{{ xiangqingdetail.line?xiangqingdetail.line['name']:"" }}</view>
							<view class="pintuan_dingdan_details_item5_t2">
								{{ $t('page_sharing_order_detail.ts') }}
								<text>{{ xiangqingdetail.line?xiangqingdetail.line['line_special']:"" }}</text>
							</view>
							<view class="pintuan_dingdan_details_item5_t2">
								{{ $t('page_sharing_order_detail.time_delivery') }}
								<text>{{ xiangqingdetail.line?xiangqingdetail.line['limitationofdelivery']:"" }}{{ $t('page_sharing_order_detail.dw') }}</text>
							</view>
						</view>
					</view>
				</view>
				<view class="pintuan_dingdan_details_item6">
					<view class="pintuan_dingdan_details_item5_title">
						<image :src="imgUrl + '/dzx_img47.png'"></image>
						<text>{{ $t('page_sharing_order_detail.Shipping_information') }}</text>
					</view>
					<view class="pintuan_dingdan_details_item6_list">
						<view class="pintuan_dingdan_details_item6_cont">
							<view class="pintuan_dingdan_details_item6_cont_l">
								<image :src="imgUrl + '/dzx_img29.png'"></image>
								<text>{{ $t('page_sharing_order_detail.Base_freight') }}</text>
							</view>
							<view class="pintuan_dingdan_details_item6_cont_r">
								<text>2000{{ price_mode.unit }}</text>
							</view>
						</view>
						<view class="pintuan_dingdan_details_item6_cont">
							<view class="pintuan_dingdan_details_item6_cont_l">
								<image :src="imgUrl + '/dzx_img50.png'"></image>
								<text>计算运费</text>
							</view>
							<view class="pintuan_dingdan_details_item6_cont_r">
								<text>2000{{ price_mode.unit }}</text>
							</view>
						</view>
						<view class="pintuan_dingdan_details_item6_cont">
							<view class="pintuan_dingdan_details_item6_cont_l">
								<image :src="imgUrl + '/dzx_img49.png'"></image>
								<text>选中优惠券</text>
							</view>
							<view class="pintuan_dingdan_details_item6_cont_r">
								<text>-2000{{ price_mode.unit }}</text>
								<image :src="imgUrl + '/dzx_img25.png'"></image>
							</view>
						</view>
					</view>
					<view class="pintuan_dingdan_details_item6_txt">
						待付金额
						<text>{{ price_mode.unit }}2998</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
// pages/shouye/shouye_zkc/shouye_zkc.js
const app = getApp();

let request = require('../../utils/require');

export default {
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData?app.globalData.top:0,
			imgUrl: app.globalData.imgUrl,
			urlimg: app.globalData.urlimg,
			weight_mode: uni.getStorageSync('weight_mode'),
			price_mode: uni.getStorageSync('price_mode'),
			xiangqingdetail: [],
			banertrue:true,
			//0是待付款，1是待审核，2是待发货，3是已发货，4是已完成
			arrlist: [
				{ id: 1, name: '拼团中', img: 'dzx_img87.png' },
				{ id: 3, name: '待打包', img: 'dzx_img88.png' },
				{ id: 4, name: '待付款', img: 'dzx_img89.png' },
				{ id: 5, name: '待发货', img: 'dzx_img90.png' },
				{ id: 6, name: '已发货', img: 'dzx_img91.png' },
				{ id: 7, name: '已完成', img: 'dzx_img92.png' }
			]
		};
	},
	onPageScroll: function(e) {
		if (e.scrollTop > this.navH + 50) {
			this.banertrue= true
		} else {
			this.banertrue= true
		}
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {
		var that = this;
		that.ids= options.order_id
		that.item_id= options.item_id
	},
	onShow() {
		var that = this;
		that.xiangqing(); //返回地址id

		let pages = getCurrentPages();
		let currPage = pages[pages.length - 1];
		if (currPage.data && currPage.data.address_id) {
			console.log(this, '222222222222222222');
			this.address_id= currPage.data.address_id
		}
		if (that.address_id) {
			that.genghuandizhi2();
		}
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {},
	methods: {
		//查看评论
		gohotpinlun(e) {
			uni.navigateTo({
				url: '/pages/indexs/hotpinlun/hotpinlun?type=1&id=' + e.currentTarget.dataset.id
			});
		},

		quzhifu(e) {
			var that = this;
			uni.showModal({
				title: '提示',
				content: '确认是否支付？',

				success(res) {
					if (res.confirm) {
						var data = {
							token: uni.getStorageSync('token'),
							id: e.currentTarget.dataset.id,
							coupon_id: that.coupon_id
						};
						request.post(`index.php?s=/api/package/doPay&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
							if (res.data.code == 1) {
								uni.showToast({
									title: res.data.data
								});
								setTimeout(() => {
									that.page= 1
									that.ispage= true
									that.arrlist= []
									that.baoguolist(that.type);
								}, 1000);
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: 'none'
								});
							}
						});
					} else {
						if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				}
			});
		},
		changeAddress() {
			uni.navigateTo({
				url: '/pages/pintuans/dizhi/dizhi?type=xuanze'
			});
		},
		//取消订单
		quxiaodingdan(e) {
			var that = this;
			var data = {
				token: uni.getStorageSync('token'),
				id: e.currentTarget.dataset.id
			};
			uni.showModal({
				title: '取消该订单仍可能会产生额外的费用',
				success(res) {
					if (res.confirm) {
						request.post(`index.php?s=/api/package/cancle_pack&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
							if (res.data.code == 1) {
								uni.showToast({
									title: res.data.data
								});
								setTimeout(() => {
									uni.navigateBack({
										delta: 0
									});
								}, 1000);
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: 'none'
								});
							}
						});
					} else {
						if (res.cancel) {
						}
					}
				}
			});
		},

		querenqianshou(e) {
			var that = this;
			uni.showModal({
				title: '提示',
				content: '确认签收该包裹？',
				success(res) {
					if (res.confirm) {
						var data = {
							token: uni.getStorageSync('token'),
							id: e.currentTarget.dataset.id
						};
						request.post(`index.php?s=/api/package/signedin&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
							if (res.data.code == 1) {
								uni.showToast({
									title: res.data.data
								});
								setTimeout(() => {
									uni.navigateBack({
										delta: 0
									});
								}, 1000);
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: 'none'
								});
							}
						});
					} else {
						if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				}
			});
		},

		genghuandizhi() {
			//跳转选择地址
			uni.navigateTo({
				url: '/pages/pintuans/dizhi/dizhi?type=xuanze'
			});
		},

		choosecoupon() {
			//跳转选择地址
			uni.navigateTo({
				url: '/pages/mys/my_usercoupon/my_yhq?type=xuanze&free=' + this.free_total
			});
		},

		wuliu(e) {
			uni.navigateTo({
				url: '/pages/chaxun/chaxun?id=' + e.currentTarget.dataset.id
			});
		},

		viewCopyTextClick: function() {
			var that = this;
			uni.setClipboardData({
				data: that.xiangqingdetail.express_num,
				success: function(res) {
					uni.getClipboardData({
						success: function(res) {
							uni.showToast({
								title: '复制成功'
							});
						}
					});
				}
			});
		},

		qupinjia() {
			uni.navigateTo({
				url: '/pages/indexs/my_dingdan_qpj/my_dingdan_qpj'
			});
		},

		jumpzuo() {
			uni.navigateBack();
		},

		xiangqing() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token'),
				id: that.ids,
				item_id: that.item_id
			};
			request.post(`index.php?s=/api/sharp.order/detail&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					console.log(res.data.data.model);
					that.xiangqingdetail= res.data.data.model
				}
			});
		},

		genghuandizhi2() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token'),
				address_id: that.address_id,
				id: that.xiangqingdetail.order_id
			};
			request.post(`index.php?s=/api/sharp.order/addressUpdate&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					uni.showToast({
						title: res.data.data
					});
					that.xiangqing();
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
			});
		}
	}
};
</script>
<style>
@import './sharing_order_detail.css';
</style>
